package com.woniu.cms.contract.core.controller;


import com.woniu.cms.contract.core.entity.Public;
import com.woniu.cms.contract.core.service.IPublicService;
import com.woniu.common.api.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author maple leaf
 * @since 2022-09-17
 */
@Api(tags = "公共合同")
@RestController
@RequestMapping("/public")
public class PublicController {

    @Autowired
    private IPublicService publicService;

    @ApiOperation("新增")
    @PostMapping
    public Result addPublic(@RequestBody Public publi){
        Result result = publicService.addPublic(publi);
        return result;

    }

    @ApiOperation("审核")
    @PutMapping
    public Result auditPublic(@RequestBody Public publi){

        Result result = publicService.auditPublic(publi);
        return result;
    }

    @ApiOperation("删除")
    @DeleteMapping("{publicCode}")
    public Result delPublic(@PathVariable String publicCode){

        Result result = publicService.delPublic(publicCode);

        return result;

    }

    @ApiOperation("分页查询")
    @GetMapping
    public Result queryPublic(String undertakeContractCode, String publicCode, Integer currentPage, Integer pageSize){

        Result result = publicService.queryPublic(undertakeContractCode, publicCode, currentPage, pageSize);
        return result;
    }

    @ApiOperation("查询单条")
    @GetMapping("{publicCode}")
    public Result queryByPublic(@PathVariable String publicCode){

        Result result = publicService.queryByPublic(publicCode);
        return result;
    }

}

